package com.sr.examination.exam.exercise.category.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;

import com.sr.examination.R;
import com.tl.commonlibrary.ui.adapter.IAdapter;
import com.tl.commonlibrary.ui.adapter.ViewHolder;
import com.tl.commonlibrary.ui.beans.ExerciseOption;
import com.tl.commonlibrary.ui.widget.ChoiceContainerLayout;

import java.util.List;

/**
 * Created by jiangzhongshan on 18/2/3.
 */

public class ChoiceAdapter extends IAdapter<ExerciseOption> {
    private boolean checkable = true;

    public ChoiceAdapter(Context context, List<ExerciseOption> datas) {
        super(context, datas, R.layout.item_choice);
    }

    public void setCheckable(boolean checkable) {
        this.checkable = checkable;
        notifyDataSetChanged();
    }

    @Override
    protected void getView(ViewHolder viewHolder, ExerciseOption entity, int position, View convertView, boolean isConvert, int itemViewType, ViewGroup parent) {
        ChoiceContainerLayout choiceContainerLayout = viewHolder.getView(R.id.choiceLayout);
        choiceContainerLayout.setCheckable(checkable);
        CheckBox letterCBox = viewHolder.getView(R.id.check_box);
        letterCBox.setEnabled(checkable);
        choiceContainerLayout.setChecked(entity.isChecked());
        letterCBox.setText(entity.getId());
        TextView contentTView = viewHolder.getView(R.id.choiceContentTView);
        contentTView.setText(entity.getDesc());
    }

    @Override
    public void onClick(View v) {

    }
}
